import * as types from './mutations_types';
import {
    student as api
} from '../../api/education';
module.exports = {
    query_basicInfo: ({
        commit
    }, {
        self,
        query
    }) => {
        api.querySinStudentInfoAction.call(self, query, data => {
            commit(types.QUERY_BASIC_INFO, data);
        });
    },
    // 新增简历
    add_resume: ({
        commit
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.addUpdateStudentInfoAction.call(self, query, data => {
                resolve();
            }, () => {
                reject();
            });
        });
    },
    // 跟踪记录查看保存信息
    save_record_info: ({
        commit
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.insertAssistantContentAction.call(self, query, data => {
                resolve();
            }, () => {
                reject();
            });
        });
    },
    // 选择已缴费时获取缴费数据
    get_payment_data: ({
        commit
    }, {
        self,
        query
    }) => {
        api.insertPayInfoAction.call(self, query, data => {
            commit(types.PAYMENT_DATA, data);
        });
    },
    // 新增学员信息，查询状态
    add_stuInfo: ({
        commit
    }, {
        self
    }) => {
        api.QueryStudentInfoConstantAction.call(self, {}, data => {
            commit(types.ADD_STU_INFO, data);
        });
    },
    // 新增退费记录
    add_charge_back_record: ({
        commit
    }, {
        self,
        info
    }) => {
        api.InsertRefundInfoAction.call(self, info, data => {});
    },
    // 跟踪记录列表
    follow_record_list: ({
        commit
    }, {
        self,
        query
    }) => {
        api.TrackInfoListAction.call(self, query, data => {
            commit(types.FOLLOWING_RECORD_LIST, data);
        });
    },
    // 删除简历
    delete_resume: ({
        commit
    }, {
        self,
        query
    }) => {
        api.stuDel.call(self, query, data => {});
    },
    // 调换咨询电话
    change_user_mobile: ({
        commit
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.exchangeUser.call(self, query, data => {
                resolve();
            }, () => {
                reject();
            });
        });
    },
    // 新增跟踪记录
    add_track_record: ({
        commit
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.InsertTrackInfoAction.call(self, query, data => {
                resolve();
            }, () => {
                reject();
            });
        });
    },
    // 新增跟踪记录里的状态选择
    add_track_record_status: ({
        commit
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.optionalStautsAction.call(self, query, data => {
                resolve();
                commit(types.OPTION_STATUS, data);
            }, () => {
                reject();
            });
        });
    },
    // 撤回简历
    withdraw_resume: ({
        commit
    }, {
        self,
        query
    }) => {
        api.stuBack.call(self, query, data => {});
    },
    // 新增缴费记录
    add_payment_record: ({
        commit
    }, {
        self,
        query
    }) => {
        api.newPayInformation.call(self, query, data => {
            commit(types.ADD_PAYMENT_RECORD, data);
        });
    },
    // 跟踪记录详情题目
    track_record_question: ({
        commit
    }, {
        self,
        query
    }) => {
        api.detailedTrackInfoAction.call(self, query, data => {
            commit(types.THE_QUESTIONS, data);
        });
    },
    // 查询人员
    query_person: ({
        commit
    }, {
        self,
        query
    }) => {
        api.queryUserInfoAction.call(self, query, data => {
            commit(types.QUERY_PERSON, data);
        });
    },
    query_StuTrackList: ({
        commit,
        dispatch
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.queryStuTrackList.call(self, query, data => {
                commit(types.QUERY_STUTRACKLIST, data);
                resolve();
                dispatch('update_page', {
                    pageNum: query.pageNum,
                    pageSize: query.pageSize
                });
            }, () => {
                reject();
            });
        });
    },
    update_page: ({
        commit
    }, page) => {
        commit(types.UPDATE_PAGE, page);
    },
    // 未分配简历列表
    query_resumeList: ({
        commit
    }, {
        self,
        query
    }) => {
        return new Promise((resolve, reject) => {
            api.unallottedResumeList.call(self, query, data => {
                commit(types.RESUME_LIST, data);
                resolve();
            }, () => {
                reject();
            });
        });
    },
    get_stuRandomAllot: ({
        commit
    }, {
        self,
        suData
    }) => {
        return new Promise((resolve, reject) => {
            api.stuRandomAllot.call(self, suData, data => {
                resolve();
            }, () => {
                reject();
            });
        });
    },
    get_stuAllot: ({
        commit
    }, {
        self,
        suData
    }) => {
        return new Promise((resolve, reject) => {
            api.stuAllot.call(self, suData, data => {
                resolve();
            }, () => {
                reject();
            });
        });
    },
    query_trackNum: ({
        commit
    }, {
        self
    }) => {
        api.trackNum.call(self, {}, data => {
            commit(types.QUERY_TRACKNUM, data);
        });
    },
    update_trackStatusF: ({
        commit
    }, data) => {
        commit(types.UPDATE_TRACKSTATUSF, data);
    },
    // 分配
    counselor_All_List: ({
        commit
    }, {
        self,
        query
    }) => {
        api.counselorAllotList.call(self, query, data => {
            commit(types.CONSULTING_LIST, data);
        });
    },
    consulting_Echarts: ({
        commit
    }, {
        self
    }) => {
        api.queryActualExpectedLegendGroupByDayAction.call(self, {}, data => {
            commit(types.CONSULTING_ECHARTS, data);
        });
    },
    break_Appointment: ({
        commit
    }, {
        self,
        query
    }) => {
        api.breakTheAppointment.call(self, query, data => {
            commit(types.BREAK_APPOINTMENT, data);
        });
    }
};